from  fastapi import WebSocket
async def websocket_en1dpoint(websocket: WebSocket):
    await websocket.accept()  # 接受 WebSocket 连接
    while True:
        data = await websocket.receive_text()  # 接收客户端消息
        await websocket.send_text(f"Message text was: {data}")  # 发送消息给客户端

